<template>
    <b-page>
        <template slot="content">
            <div class="business-info-item" v-for="item in dataList">
                <div class="business-info-title">{{item.title}}</div>
                
                <div class="business-info-content">
                    <ul class="content-left">
                        <li class="flex" v-for="itemchild in item.left">
                            <div>{{itemchild.text}}</div>
                            <div>
                                <template v-if="itemchild.change">
                                    {{change(itemchild.change,itemchild.val)}}
                                </template>
                                <template v-else>
                                    {{data[itemchild.val] || '—'}}
                                </template>
                            </div>
                        </li>
                    </ul>
                    <ul class="content-right">
                        <li v-for="itemchild in item.right">
                            <div v-if="data[itemchild.val]" class="overlay-img" @click="enlargeImg(data[itemchild.val],itemchild.text)">
                                <a href="javascipt:void(0);">
                                    <Icon type="ios-search-strong"></Icon>
                                    {{itemchild.text}}照片
                                </a>
                            </div>
                            <img v-if="data[itemchild.val]" :src="IMG_SEE +data[itemchild.val]" :alt="itemchild.text">
                        </li>
                    </ul>
                </div>
            </div>
            <Modal
                v-model="showEnlarge"
                :width="1000"
                :title="enlargeTitle"
                >
                <div class="enlargeImg">
                    <img v-if="enlargeUrl" :src="IMG_SEE + enlargeUrl" :alt="enlargeTitle">
                </div>
                
            </Modal>
        </template>
    </b-page>
</template>

<script>
    import BPage from 'components/BPage';
    import {setBusinessType} from 'commons/json/businessType';
    import {setBusinessScope} from "commons/json/category.js";
    import { IMG_SEE } from '@/service/api';
    export default {
        components: { BPage },
        data(){
            return {
                showEnlarge: false,
                enlargeUrl: '',
                enlargeTitle: '',
                IMG_SEE: IMG_SEE,
                dataList: [
                    {
                        title: '营业执照信息',
                        left: [
                            { text: '企业名称' , val: 'name'},
                            { text: '统一社会信用代码' , val: 'socialCode'},
                            { text: '营业执照详细地址' , val: 'address'},
                            { text: '企业经营类型' , val: 'businessType', change: 'setBusinessType'},
                            { text: '经营范围' , val: 'scope'},
                        ],
                        right: [
                            { text: '营业执照副本电子版' , val: 'businessPhoto'},
                        ]
                    },
                    {
                        title: '道路运输经营许可证信息',
                        left: [
                            { text: '道路运输经营许可证号' , val: 'licenseNo'},
                            { text: '道路运输经营许可证发证日期' , val: 'licensePublish'},
                            { text: '道路运输经营许可证开始日期' , val: 'licenseBegin'},
                            { text: '道路运输经营许可证结束日期' , val: 'licenseEnd'},
                            { text: '详细经营范围' , val: 'businessDetailType', change: 'setBusinessDetailType'},
                        ],
                        right: [
                            { text: '道路运输经营许可证信本电子版' , val: 'roadPhoto'},
                        ]
                    },
                    {
                        title: '企业法人信息',
                        left: [
                            { text: '法人姓名' , val: 'legalPerson'},
                            { text: '法人身份证号' , val: 'IDNumber'},
                            { text: '法人联系电话' , val: 'legalMobile'},
                                               
                        ],
                        right: [
                            { text: '法人身份证正面' , val: 'idfront'},
                            { text: '法人身份证反面' , val: 'idback'},        
                        ]
                    }
                ],
                data: {},
            }
        },
        created() {
            this.init();
        },
        methods: {
            init() {
                this.$ajax(this.$api.account.detail,'',(RES)=>{
                    this.data = RES.content;
                },(error)=>{
                    console.log(error);
                    this.$Message.error('获取不到账号信息，请稍后再试');
                })
            },
            change(fun,val) {
                return this[fun](this.data[val]);
            },
            setBusinessType(val) {
                return setBusinessType(val);
            },
            setBusinessDetailType(val) {
                return setBusinessScope(this.data.category,val);
            },
            enlargeImg(url,title) {
                if(!url) return;

                this.showEnlarge = true;
                this.enlargeUrl = url;
                this.enlargeTitle = title;
            }
        }
    }
</script>

<style lang="less" rel="stylesheet/less">
    .business-info-item{
        margin-bottom: 20px;
        background-color: #fff;

        .business-info-title{
            height: 50px;
            line-height: 50px;
            font-size: 16px;
            padding-left: 30px;
            color: @color-Title;
            border-bottom: 1px solid @color-Divider;
        }

        .business-info-content{
            display: flex;
            padding: 30px 50px;

            .content-left{
                flex: 1;
                li{
                    margin-bottom: 20px;
                    div{
                        display: inline-block;
                        font-size: 14px;
                        line-height: 20px;

                        &:first-child{
                            width: 220px;
                            //text-align: right;
                            margin-right: 10px;
                            color: @color-Sub;
                        }

                        &:last-child{
                            flex:1;
                            color: @color-Content;

                            img{
                                width: 200px;
                                margin-top: 4px;
                            }
                        }
                    }
                }
            }

            .content-right{
                width: 300px;
                overflow: hidden;

                li{
                    position: relative;
                    width: 100%;
                    height: 200px;
                    margin-bottom: 20px;
                    background-color: @color-Background;

                    .overlay-img{
                        position: absolute;
                        width: 100%;
                        height: 100%;

                        a{
                            position: absolute;
                            top: 50%;
                            left: 50%;
                            text-align: center;
                            transform: translate(-50%,-50%);
                            padding: 4px;
                            color: #fff;
                            background-color: rgba(0,0,0,.5);
                            border-radius: 10px;
                        }
                    }

                    img{
                        display: block;
                        height: 100%;
                        margin: 0 auto;
                    }
                }
            }
        }
    }

    .enlargeImg{
        img{
            display: block;
            margin: 0 auto;
            max-width: 960px;
        } 
    }
</style>